<%-- 
    Document   : viewStat
    Created on : 2009-10-21, 21:56:50
    Author     : ben
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="roomarrange.*"
        import="org.springframework.context.ApplicationContext"
        import="org.springframework.context.support.ClassPathXmlApplicationContext"
        import="javax.sql.DataSource"
        import="java.text.SimpleDateFormat"

        %>
<%
        String sRoom;
        String[] sRc;
        String app = session.getAttribute("app").toString();
        String ls_sdate = session.getAttribute("sdate").toString();
        int iroomid = (Integer) session.getAttribute("iroomid");
        ApplicationContext ctx = new ClassPathXmlApplicationContext("SpringConfig.xml");
        DataSource ds = (DataSource) ctx.getBean("dataSourceDBDirect");
//DataSource ds = (DataSource) ctx.getBean("dataSourcePool");
        DataJdbcDao taskDao = new DataJdbcDao();
        taskDao.setDataSource(ds);
        sRoom = taskDao.getRoomName(iroomid);
        sRc = taskDao.getRoomStat(iroomid, ls_sdate,app);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>查看占用状态</title>
        <style type="text/css">
            /* CSS Document */

            body {
                font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
                color: #4f6b72;
                background: #E6EAE9;
            }

            a {
                color: #c75f3e;
            }

            #mytable {
                width: 92%;
                padding: 0;
                margin: 0;
            }

            caption {
                padding: 0 0 5px 0;
                width: 700px;
                font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
                text-align: right;
            }

            th {
                font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
                color: #4f6b72;
                border-right: 1px solid #C1DAD7;
                border-bottom: 1px solid #C1DAD7;
                border-top: 1px solid #C1DAD7;
                letter-spacing: 2px;
                text-transform: uppercase;
                text-align: left;
                padding: 6px 6px 6px 12px;
                background: #CAE8EA  no-repeat;
            }
            /*power by www.winshell.cn*/
            th.nobg {
                border-top: 0;
                border-left: 0;
                border-right: 1px solid #C1DAD7;
                background: none;
            }

            td {
                border-right: 1px solid #C1DAD7;
                border-bottom: 1px solid #C1DAD7;
                font-size:11px;
                padding: 6px 6px 6px 12px;
                color: #4f6b72;
            }
            /*power by www.winshell.cn*/

            td.alt {
                background: #F5FAFA;
                color: #797268;
            }

            th.spec {
                border-left: 1px solid #C1DAD7;
                border-top: 0;
                background: #fff no-repeat;
                font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
            }

            th.specalt {
                border-left: 1px solid #C1DAD7;
                border-top: 0;
                background: #f5fafa no-repeat;
                font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
                color: #797268;
            }
            /*---------for IE 5.x bug*/
            html>body td{ font-size:11px;}
            body,td,th {
                font-family: 宋体, Arial;
                font-size: 12px;
            }
        </style>

    </head>

    <body>
        <div id="myf" align="center">
            <h2> <%=sRoom%> 时间：<%=ls_sdate%></h2>
            <h3><strong>图标注释：绿色代表该时间段可用 红色代表该时段申请已通过审批 黄色代表该时段申请尚未审批</strong></h3>
        </div>
        <div id="myt" align="center">
            <table id="mytable" cellspacing="0" >
                <%
        int i = 0;
        int j = 0;
        int itk = 0;
        String ls_tmp = "";
        String ls_tmp2 = "";
        String sColor = "#33FF00";
        String sColor2 = "#33FF00";
        String sTmp = "";
        String sTmp2 = "";
        int istat = 0;
        for (i = 0; i < 48; i++) {
            //会议室为7am-7pm
            if (app.equalsIgnoreCase("room")){
                if (i < 14 || i > 38) {
                    continue;
                }
            }
            if (i < 20) {
                if (i % 2 == 0) {
                    ls_tmp = "0" + i / 2 + ":00";
                    ls_tmp2 = "0" + i / 2 + ":30";
                    itk = 0;
                } else {
                    ls_tmp = "0" + i / 2 + ":30";
                    itk = 1;

                }
            } else {
                if (i % 2 == 0) {
                    ls_tmp = i / 2 + ":00";
                    ls_tmp2 = i / 2 + ":30";
                    itk = 2;
                } else {
                    ls_tmp = i / 2 + ":30";
                    itk = 3;

                }
            }
            j++;
            //画表格

            out.println("<tr>");
            out.println("<th width=\"50\" ><div align=\"center\">" + ls_tmp + "</div></th>");
            for (int k = 0; k < 49; k++) {
                if (sRc[k] == null) {
                    break;
                }
                //绿色#33FF00 黄色#FFFF66 红色#FF0000
                istat = Integer.parseInt(sRc[k].substring(0, 1));
                sTmp = sRc[k].substring(2).trim();

                //正点的
                if (sTmp.equals(ls_tmp)) {
                    if (istat < 4) {
                        sColor = "#FFFF66";
                    } else {
                        sColor = "#FF0000";
                    }
                }
            }
            out.println("<td bgcolor=\"" + sColor + "\">&nbsp;</td>");
            out.println("</tr>");

            //cls
            ls_tmp = "";
            sColor = "#33FF00";
            sColor2 = "#33FF00";
        }


                %>
            </table>
        </div>
    </body>
</html>
